package com.sh.sample.config;

import com.sh.common.config.ConfigDataManager;
import com.sh.common.config.annotation.ConfigDataCustomization;
import com.sh.common.config.source.RawJSONSource;

import java.util.Arrays;

/**
 * TT
 *
 * @author 张力
 * @date 2025/3/20 15:22
 */
public class ConfigSample {
    public static void main(String[] args) throws Exception {


        ConfigDataCustomization custom = ConfigDataCustomization.newInstance()
                .setSource(RawJSONSource.class)
                .setPkg("com.sh.sample.config")
                .setPath("D:\\code\\base-sample\\config\\json");

        ConfigDataManager.getInstance().init(custom);
        ItemConfig itemConfig = ConfigDataManager.getInstance().getById(ItemConfig.class, 1);
        System.out.println(itemConfig.getName());
//        System.out.println(Arrays.toString(itemConfig.getAttrs()));


        /*ItemConfig itemConfig = new ItemConfig();
        itemConfig.setId(1);
        itemConfig.setName("月光宝剑");
        itemConfig.setAttrs(new int[]{1,2,3,4,5});

        ObjectMapper mapper = new ObjectMapper();


        List<ItemConfig> list = new ArrayList<>();
        list.add(itemConfig);


        ItemConfig itemConfig2 = new ItemConfig();
        itemConfig2.setId(2);
        itemConfig2.setName("月光宝剑2");
        itemConfig2.setAttrs(new int[]{1,2,3,4,5});

        list.add(itemConfig2);

        String json = mapper.writeValueAsString(list);
        System.out.println(json);*/

    }
}


